Skip to content

fix(web): copying items within one list keeps their list markers - #39150

Merged
juliusmarminge merged 17 commits into
pingdotgg:mainfrom
StiensWout:t3/1196-copying-part-of-a-numbered-list-drops-it
Nov 19, 2026
Merged

juliusmarminge merged 17 commits into
pingdotgg:mainfrom
StiensWout:t3/1196-copying-part-of-a-numbered-list-drops-it

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

On web and desktop, copying several items within a chat list dropped their numbers or bullets because the selection cloned the items without their list. Copied Markdown and HTML now keep the list and its displayed numbering, omitting empty items at the edges of selections that cross nested lists or continue into surrounding text. Copied Markdown also keeps the first selected task item's checkbox state when the selection starts at its label.

Fixes #39149
Related: #22035

Reproduction on main

Commit 470ca63499 (main). The pasted items appear as unnumbered text. The cause is at apps/web/src/markdown-clipboard.ts:514. Ran pnpm scenarios:prove scripts/scenarios/copied-items-within-numbered-list-keep-numbers.e2e.ts --base main with the repro test added: it failed in 2 of 2 runs on a clean checkout, with The pasted items keep their displayed list numbers in the output.

Evidence

Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit

Steps: Copying two items within a numbered list keeps their numbers: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /86c0d370-69d0-42b1-bc7a-a286d0ba49a6/mcp:0cb7b251-113b-4c7d-b674-743ace323b9d; locator.tap getByRole("button", name: /^Agent Steps/); locator.waitFor getByText("Configure") → visible; browser.evaluate ; browser.keyboard.press ControlOrMeta+C; locator.tap getByRole("textbox"); browser.keyboard.press ControlOrMeta+V; browser.evaluate ; app.screenshot pasted-list-items; browser.evaluate .

Proven: the scenario fails on base 6dc7fdc8e8 and passes on head dc4627cde7.

Before After
Commit 6dc7fdc8e8 dc4627cde7
Result Fails: ASSERTION_FAILED: The pasted items keep their displayed list numbers: expected null to equal ["2. Configure","3. Deploy"] Passes
pasted list items Before: pasted list items After: pasted list items
failure Before: failure
Recording Before: Recording After: Recording
Scenario source: scripts/scenarios/copied-items-within-numbered-list-keep-numbers.e2e.ts
/// <reference lib="dom" />
import { expect } from "e2e";

import { test, WEB } from "./t3.ts";

test(
  "Copying two items within a numbered list keeps their numbers",
  WEB,
  async ({ t3, app, browser, screen }) => {
    const project = await t3.project("demo");
    const thread = await t3.thread({
      project,
      title: "Steps",
      messages: ["Steps:\n\n1. Install\n2. Configure\n3. Deploy\n\nThen report back."],
    });
    await t3.open(thread);
    await screen.getByRole("button", /^Agent Steps/).tap();
    await screen.getByText("Configure", { exact: true }).waitFor();

    await browser.evaluate(() => {
      const items = [...document.querySelectorAll("[data-user-message-body] ol > li")];
      const start = items.find((item) => item.textContent === "Configure")?.firstChild;
      const end = items.find((item) => item.textContent === "Deploy")?.firstChild;
      if (!start || !end) throw new Error("Could not find the two list items");
      const range = document.createRange();
      range.setStart(start, 0);
      range.setEnd(end, end.textContent?.length ?? 0);
      const selection = window.getSelection();
      selection?.removeAllRanges();
      selection?.addRange(range);
      return null;
    });
    await browser.keyboard.press("ControlOrMeta+C");
    await screen.getByRole("textbox").tap();
    await browser.keyboard.press("ControlOrMeta+V");

    const numberedItems = await browser.evaluate(() => {
      const list = document.querySelector<HTMLOListElement>('[role="textbox"] ol');
      if (!list) return null;
      return [...list.querySelectorAll(":scope > li")].map(
        (item, index) => `${list.start + index}. ${item.textContent?.trim()}`,
      );
    });
    await app.screenshot("pasted-list-items");
    expect(numberedItems, "The pasted items keep their displayed list numbers").toEqual([
      "2. Configure",
      "3. Deploy",
    ]);

    const renderedItems = await browser.evaluate(() =>
      [...document.querySelectorAll('[role="textbox"] ol > li')].map(
        (item) => `${item.getAttribute("data-marker")} ${item.textContent?.trim()}`,
      ),
    );
    expect(renderedItems, "The composer renders both pasted markers").toEqual([
      "2. Configure",
      "3. Deploy",
    ]);
  },
);

Tests

  • 55baad4bb2 adds the failing test, alone, before the fix.
  • cd apps/web && pnpm exec vp test run src/components/ChatMarkdown.browser.test.tsx -t "with the markers its list shows" passed on head.
  • pnpm exec vp run check:changed passed on head.

Not in this change

  • Mobile's native Copy writes ordered HTML without a start number, so a rich paste of later items restarts at 1.
  • Selecting text, a link label, or code within a single list item keeps its existing copy behavior without that item's marker.
  • A selection that starts mid-item keeps the marker on the partial text, as copies past the list already do.
  • Copied HTML continues to strip form controls, including task checkboxes.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Review findings fixed by GPT 6.2 Sol, in Codex
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
  • Also reviewed by cubic, run locally by a program, with no score
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol

StiensWout and others added 15 commits November 19, 2026 15:31
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ries

Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 19, 2026
@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 19, 2026
juliusmarminge and others added 2 commits November 19, 2026 14:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Clipboard range cloning now preserves list markers when copying selected list content. Browser tests cover list variants, partial selections, and boundary items. An end-to-end test verifies that pasted numbered-list items retain their displayed numbers.

Changes: Clipboard list markers

Layer / File(s) Summary
Selection cloning and marker restoration
apps/web/src/markdown-clipboard.ts
The clipboard payload builder uses adjusted range cloning. It trims empty boundary items and restores list wrappers, task checkboxes, and ordered-list numbers.
Copy and paste validation
apps/web/src/components/ChatMarkdown.browser.test.tsx, scripts/scenarios/copied-items-within-numbered-list-keep-numbers.e2e.ts
Browser tests cover list selection variants and rich-paste output. The end-to-end test checks that pasted items retain numbers 2 and 3.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: bugfix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 619d1

This change keeps list markers when copying multiple items within a chat list. It is scoped to the clipboard copy path and has targeted test coverage. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: copying several items within one chat list now keeps their list markers (numbers or bullets). The raw summary and PR objectives both describe this fix in markdown-cli…
Description check Passed The description follows the template. It has a Problem section that explains the bug and its reproduction on main. It has a Change section that explains the fix and the omitted edge items. It has a Sc…
Linked Issues check Passed [#39149] requires that copying from the start of "Configure" through the end of "Deploy" in a three-item numbered list keeps the displayed numbers 2 and 3 when pasted into the composer. At head, apps/…
Out of Scope Changes check Passed Changed files are apps/web/src/markdown-clipboard.ts, apps/web/src/components/ChatMarkdown.browser.test.tsx, and the e2e scenario script. Additional behaviors (empty selection-boundary trimming, first…
Full details: Title check

Explanation

The title states the main change: copying several items within one chat list now keeps their list markers (numbers or bullets). The raw summary and PR objectives both describe this fix in markdown-clipboard.ts and related tests. The title follows conventional commit format and is specific to the change, so it passes.

Full details: Description check

Explanation

The description follows the template. It has a Problem section that explains the bug and its reproduction on main. It has a Change section that explains the fix and the omitted edge items. It has a Scope section that links the issue #39149 and the related PR. It has a Verification section with the failing-then-passing scenario proof, test commands, and before/after evidence. The description also names the model and harness that did the work, as the template requests. The author lists the scope limits under 'Not in this change'. Minor gaps: the Scope section does not say why no issue is needed, but a linked issue exists, so that is not required. The Verification section lists the test commands and before/after evidence, which the template asks for.

Full details: Linked Issues check

Explanation

[#39149] requires that copying from the start of "Configure" through the end of "Deploy" in a three-item numbered list keeps the displayed numbers 2 and 3 when pasted into the composer. At head, apps/web/src/markdown-clipboard.ts defines numberedListItems(list), which derives displayed numbers from the list start and li value attributes. serializeList uses it for ordered-list output, so the displayed numbers are emitted. The e2e scenario scripts/scenarios/copied-items-within-numbered-list-keep-numbers.e2e.ts asserts ["2. Configure", "3. Deploy"]. The PR reports that this scenario fails on base 6dc7fdc and passes on head dc4627c. The head commit 619d1b0 is newer than dc4627c; its diff could not be read, so its effect on the paste path is not verified. The clone-path code in markdown-clipboard.ts was truncated in the read, so the clone fix itself rests on the change summary and the reported proof run. No coding requirement of #39149 is shown unmet.

Full details: Out of Scope Changes check

Explanation

Changed files are apps/web/src/markdown-clipboard.ts, apps/web/src/components/ChatMarkdown.browser.test.tsx, and the e2e scenario script. Additional behaviors (empty selection-boundary trimming, first task item checkbox state in copied Markdown, LIST_ITEM_CHECKBOX reuse) act on the same list-item copy path as #39149. Commit history shows related fixes for task markers and nested task numbering, which the PR description lists as part of the same copy behavior. No unrelated change was demonstrated. The diff for head 619d1b0 and the clone-path hunks could not be read, so the connection of those hunks is inferred from the summary and commit subjects. Latest commit 619d1b0 removes tests the author describes as passing without the fix; this does not add out-of-scope code.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dc4627c and 619d1b0.

Files selected for processing: 1

  • apps/web/src/components/ChatMarkdown.browser.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Web app, Chromium, 1280×800, light theme; fresh synthetic data on both commits. Open a thread containing 1. Install, 2. Configure, 3. Deploy. Select Configure through Deploy, copy, and paste into the empty composer.

The scenario fails on base and passes on head: base pastes unnumbered lines; head retains numbers 2 and 3. Head also retains the selected list structure in copied Markdown and HTML.

Before After
Commit 3dff4daf14 619d1b03fc
Selection Before: selected list items After: selected list items
Pasted result Before: numbers dropped After: numbers 2 and 3 retained
Recording Before interaction After interaction

Scenario source.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 19, 2026
@juliusmarminge
juliusmarminge merged commit ff9efe8 into pingdotgg:main Nov 19, 2026
59 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 19, 2026
rynfar added a commit to rynfar/t3code that referenced this pull request Nov 20, 2026
…ltas (#453)

* feat(native): port #444 Part B Sidebar, Thread & Transcript parity deltas

Port all remaining Sidebar, Thread View, and Transcript parity deltas from upstream `4121b30..80cf4f7` and flip `TV-LINEAGE` and `TR-WORK` to `done` in `apps/native/parity/LEDGER.md`.

Sidebar (`SB-ROW`, `SB-SECTIONS`, `SB-MENU`, `SB-UNDO`, `SB-SEARCH`, `SB-GROUPING`):
- Regenerating title glimmer (`pingdotgg#29383`)
- Settle-undo position restore via `plan_undo_for_thread` + `UnsettleRestore`/`ReorderActive` (`pingdotgg#33248`)
- Clear opened failed badge in sidebar rows and collapsed folder dots (`pingdotgg#28616`)
- Suppress `Done` badge for stopped/interrupted/cancelled runs (`pingdotgg#37475`)
- 1h snooze clock-minute rounding (`pingdotgg#36785`)
- Opening a delegated task selects its listed parent ancestor (`pingdotgg#37500`)
- Side-chat children included in worktree deletion check (`pingdotgg#36800`)
- Failed message search error state in sidebar search and command palette (`pingdotgg#38155`)
- Jump-hint modifier recheck after hold delay (`pingdotgg#38545`)
- Command palette `Failed` status pill prioritized over background `Waiting` (`pingdotgg#38968`)

Thread & Transcript (`TV-HISTORY`, `TV-LINEAGE`, `TV-FOLLOW`, `TR-WORK`, `TR-MARKDOWN`, `TR-CITE`, `TR-MCPAPP`):
- Subagent history model preservation via `merge_older_subagents` (`pingdotgg#38724`) and hide Resume when `supportsNativeResume` is false without an unsent continuation source (`pingdotgg#39229`)
- Cancel active smooth scroll in `keep_end` so finished-while-away threads open at end (`pingdotgg#38963`)
- MCP PR/CI work-log rows & summaries (`pingdotgg#26751`, `pingdotgg#26752`) and Windows `pwsh`/`powershell`/`cmd` launcher unwrapping (`pingdotgg#38946`)
- Leading-space user markdown preservation (`pingdotgg#38079`), RTL `<details>` and template cards (`pingdotgg#36876`, `pingdotgg#36922`), `Cite` on `send_to_user` rows (`pingdotgg#36858`), home/host paths out of workspace folder (`pingdotgg#39146`), and code/list/email copy serialization fixes (`pingdotgg#36712`, `pingdotgg#36830`, `pingdotgg#36867`, `pingdotgg#36915`, `pingdotgg#37284`, `pingdotgg#39150`)
- MCP app content-block filtering for stripped images (`pingdotgg#31338`), teardown generation race test (`pingdotgg#30387`), and pre-query/fragment download filename derivation (`pingdotgg#30712`)

* fix(native): address PR #453 review findings

Address all 3 review findings from `@d1-reviewer` (`pingdotgg#847`):
1. Remove unwired DOM-HTML Markdown re-serialization helpers (`wrap_inline_code`, `serialize_markdown_anchor`, `escape_markdown_prose`, `ListCopyItem`, `serialize_list_slice`) from `crates/core/src/markdown/clipboard.rs` and update `TR-MARKDOWN` in `apps/native/parity/LEDGER.md` accurately.
2. Add `restore_preserved_leading_whitespace` and wire `user_markdown_view` with a `Copy` (`Cmd+C`) action interceptor (`crates/app/src/transcript/markdown.rs`, `messages.rs`) so user-message Copy and Cite restore ASCII spaces/tabs while preserving literal user-typed NBSPs (`pingdotgg#38079`), verified by GPUI test `user_markdown_copy_restores_leading_spaces_and_preserves_literal_nbsp`.
3. Fetch omitted family side chats via `fetch_family_side_chats` alongside `ORCHESTRATION_GET_WORKTREE_THREAD_IDS` in `delete_thread_then` (`crates/app/src/sidebar/controller.rs`, `pingdotgg#36800`) before calling `has_other_worktree_occupants`, verified by GPUI test `worktree_cleanup_prompt_excludes_omitted_family_side_chats` (and fixed `late_teardown_does_not_close_replacement_host` under `--features snapshot` in `transcript/mcp_app.rs`).
HNRow pushed a commit to HNRow/r3code that referenced this pull request Nov 20, 2026
…gdotgg#39150)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit ff9efe8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Copying part of a numbered list drops its numbers

2 participants